<?php

class Member_serviceController extends AdminController {

    public function filters() {
        return array(
            'accessControl', // perform access control for CRUD operations
        );
    }

    public function actionReport()
    {
        
        $this->layout = '//layouts/empty';
        $network_id = str_replace('.', '', function_lib::uri_segment(5)); 
        $date_val = str_replace('.', '', function_lib::uri_segment(6)); 
        $bonus= new Bonus_helper;
//        //if(!isset($_POST['date'],$_POST['network_id']))
//       // {
//             
//              
//
//            //summary bonus
//            $summary=$bonus->summary_bonus($network_id);
//
//            //statement
//            $statement=$bonus->statement_bonus($network_id);
//
//            //history withdraw
//            $history_withdraw=$bonus->history_withdraw($network_id);
//
//            //history upgrade
//            $history_upgrade=$bonus->history_upgrade($network_id,$merge=true);
//             $this->render(
//                'report',array(
//                   'summary'=>$summary,
//                    'network_id'=>$network_id,
//                    'statement'=>$statement,
//                    'history_withdraw'=>$history_withdraw,
//                    'history_upgrade'=>$history_upgrade,
//                    'bonus'=>$bonus,
//                    //'bonus'=>$bonus,
//                 //   'value'=>$value,
//                ));
//      //  }
//       
//       
    
     if(isset($_POST['date'],$_POST['network_id']))
        {
//          $statement=$bonus->statement_bonus($_POST['network_id']);
//            $this->renderPartial('statement',array(
//            //'statement' => $statement,
//            'date_start' => $statement['date_start'],
//            'date_end' => $statement['date_end'],
//            'date_diff' => $statement['date_diff'],
//            'data' => $statement['data'],
//            'total' => $statement['total'],
//        ));
         
            $statement_detail=$bonus->statement_detail($_POST['network_id'], $_POST['date']);
            
            $this->renderPartial('statement_detail', array(
            'data' => $statement_detail['data'],
            'percent' => $statement_detail['percent'],
            'bonus' => $statement_detail['bonus'],
            'cut_index' => $statement_detail['cut_index'],
            'cut_adm' => $statement_detail['cut_adm'],
            'subtotal' => $statement_detail['subtotal'],
            'total' => $statement_detail['total'],
        ));
        } 
        
       
    }
    
    public function actionAutologin() {
        $username = function_lib::uri_segment(5);

        Yii::app()->controller->redirect(array('/member/login/auto/' . $username));
    }

    public function loadModel($id) {
        $model = sys_member::model()->findByPk($id);
        if ($model === null)
            throw new CHttpException(404, 'The requested page does not exist.');
        return $model;
    }
    
//    public function actionStatment_detail($value)
//    {
//        echo $value;
//    }

}
